package dal

import (
	commonTools "algo-sdk-go/common/tools"
	"algo-sdk-go/framework/middleware/db/mongodb/dbops"
	"algo-sdk-go/project/matchmaking/common/constant"
	"algo-sdk-go/project/matchmaking/domain/models/valueobject"
	"algo-sdk-go/project/matchmaking/domain/port/repo/ops"

	"go.mongodb.org/mongo-driver/bson"
)

func LoadUserProfileFilter(condition ops.Condition) bson.M {
	filter := dbops.GetFilter(
		ops.WithUserNumsRemoveZero(condition.UserNumList, constant.DBUserNum),
		ops.WithGender(condition.Gender),

		ops.WithAgeRange(condition.AgeRange),
		ops.WithHeightRange(condition.HeightRange),
		ops.WithWeightRange(condition.WeightRange),
		ops.WithIncomeRange(condition.IncomeRange),
		ops.WithEducationRange(condition.EducationRange),

		dbops.MatchFuzzyWord(constant.DBOccupation, []string{condition.Occupation}),
		dbops.MatchFuzzyWord(constant.DBHometown, commonTools.Cast(condition.HometownPreference, valueobject.GetAddressProvince)),
		dbops.MatchFuzzyWord(constant.DBHometown, commonTools.Cast(condition.HometownPreference, valueobject.GetAddressDistrict)),
		dbops.MatchFuzzyWord(constant.DBCurrentResidence, commonTools.Cast(condition.CurrentResidencePreference, valueobject.GetAddressProvince)),
		dbops.MatchFuzzyWord(constant.DBCurrentResidence, commonTools.Cast(condition.CurrentResidencePreference, valueobject.GetAddressDistrict)),

		ops.ParentsRetirement(condition.ParentsHasPension),
		ops.WithMaritalStatus(condition.MaritalStatus),
	).Default(ops.WithoutDelete()).AndOperator()

	return filter
}

func LoadNearestRecommendUserFilter() bson.M {
	filter := dbops.GetFilter(
	//ops.WithNearestTime(),
	).Default(ops.WithoutDelete()).AndOperator()

	return filter
}
